package dcpb.re;

public class Cost implements AutoCloseable {
    private long start;
    private String name;

    public Cost() {
        this.start = System.currentTimeMillis();
    }
    public Cost(String name) {
        this.name=name;
        this.start = System.currentTimeMillis();
    }

    @Override
    public void close() {
        if(name!=null) System.out.println(name+" cost: " + (System.currentTimeMillis() - start));
        else System.out.println("cost: " + (System.currentTimeMillis() - start));
    }
}
